﻿@model IEnumerable<CmsPageControl>

@{
    var showNoControls = !Model.Any();
    ResFile = "cms_Pages";
}

@functions{   
   string PageControlTitle(CmsPageControl control){
       return control.CommonPageControlType == PageControlTypeKind.ModulePart ?
           string.Format("{0}: {1}", control.PageControlTypeDescription, control.Module.ModuleName) :
           control.PageControlTypeDescription;
   }
   string GenerateId(){
       return Guid.NewGuid().ToString();
   }
   string MinOrMax(int index, bool isHeader = true){
       return index == 0 ? 
           (isHeader ? 
           "b-icon_expand_min" : "") :
           (isHeader ?
           "b-icon_expand_max" : "style=display:none");
   }
   string NoControlsVisible(bool showNoControls)
   {
       return !showNoControls ?
           "style=display:none" :
           "";
   }
}

<div class="b-form b-form_bordered b-form_theme_white template-region template-region-no-controls" @NoControlsVisible(showNoControls)>
    <div class="b-form__head b-form__head_grey g-clear">
    	<h3 class="b-form__title"></h3>
	</div>
	<div class="b-form__body">
        <p>@_("No controls here")</p>
    </div>
</div>
@if (!showNoControls)
{
    int count = 0;
    int maxCount = Model.Count();
    foreach (var item in Model)
    {
        Html.RenderPartial("PageControlItem", new { Model = item, RenderMoveUp = count > 0, RenderMoveDown = count < maxCount - 1, IsMinState = count == 0 }.ToExpando());
        count++;
    }
}